
//===----------------------------------------------------------------------===//
// Function
//===----------------------------------------------------------------------===//

func euclidGCF(_ a: Int, _ b: Int) -> Int {
    let answer: Int
    if a%b == 0 {
        answer = b
    } else {
        answer = euclidGCF(b, a%b)
    }
    return answer
}

//===----------------------------------------------------------------------===//
// Demo
//===----------------------------------------------------------------------===//

let pairs: [(Int, Int)] = [
    (1, 2),
    (10, 5),
    (7657, 663),
    (5789, 492),
    (112, 2296),
]

for (a, b) in pairs {
    let gcf = euclidGCF(a, b)
    print("GCF(\(a), \(b)) = \(gcf)")
}
